package com.whsxt.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whsxt.domain.ProdComm;
import com.whsxt.service.ProdCommService;
import com.whsxt.vo.ProdCommResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-03-16 15:40
 * @Description:
 */
@RestController
@RequestMapping("/prod/prodComm")
@Api(tags = "商品评论接口")
public class ProdCommController {


    @Autowired
    private ProdCommService prodCommService;


    @GetMapping("/page")
    @ApiOperation(value = "分页查询商品评论")
    public ResponseEntity<IPage<ProdComm>> prodCommPage(Page<ProdComm> page, ProdComm prodComm) {
        IPage<ProdComm> iPage = prodCommService.findProdCommPage(page, prodComm);
        return ResponseEntity.ok(iPage);
    }


    //前台====================

    @GetMapping("/prodComm/prodCommData")
    @ApiOperation(value = "前台查询商品的评论总览")
    public ResponseEntity<ProdCommResult> getFrontProdComm(Long prodId) {
        ProdCommResult result = prodCommService.getFrontProdComm(prodId);
        return ResponseEntity.ok(result);
    }


    @GetMapping("/prodComm/prodCommPageByProd")
    @ApiOperation(value = "前台查询商品的评论")
    public ResponseEntity<Page<ProdComm>> getFrontProdCommPage(Page<ProdComm> page, Long prodId, Integer evaluate) {
        Page<ProdComm> result = prodCommService.getFrontProdCommPage(page, prodId, evaluate);
        return ResponseEntity.ok(result);
    }


}
